<?php session_start(); ?>
<?php
 if(!$_SESSION['uname']){
  echo "你没有权限访问此页面!";
  return false;
}
$uid=$_SESSION['uid'];
?>
<?php include("../inc/db_config.inc"); ?>
<?php
if(isset($_REQUEST['format'])&&$_REQUEST['format']!=""){
    $p_format=$_REQUEST['format'];
}else{
    $p_format="";
}
if(isset($_REQUEST['title'])&&$_REQUEST['title']!=""){
    $cata_title=$_REQUEST['title'];
}else{
    if($p_format=="json"){
            echo '{"Status":0,"ReturnCode":"分类名称不能为空"}';
            return false;
        }
    echo "简介名称不能为空<a href='javascript:history.back()'>返回</a>";
    return false;
}
if(isset($_REQUEST['description'])&&$_REQUEST['description']!=""){
    
			$cata_desc =$_REQUEST['description'];
		
}else{
    $cata_desc="暂无";
}
if(isset($_REQUEST['private'])&&$_REQUEST['private']!=""){
    $cata_status=$_REQUEST['private'];
}else{
    $cata_status=0;
}


date_default_timezone_set("Asia/Shanghai"); //北京时间
$cata_created=date("Y-m-d H:i:s");
//echo "insert into type (name,cataDesc,created,status) values('$cata_title','$cata_desc','$cata_created','$cata_status')";
$result_post=mysql_query("insert into intro (uid,title,created,description,private) values('$uid','$cata_title','$cata_created','$cata_desc','$cata_status')");
if(mysql_affected_rows()>0){
    if($p_format=="json"){
            $getID=mysql_insert_id();
            echo '{"Status":1,"ReturnCode":"添加成功","ID":'.$getID.'}';
            return false;
        }
    $ref=$_SERVER['HTTP_REFERER'];    
    echo "添加成功!页面会在1秒钟后自动返回.<script type='text/javascript'>setTimeout(function(){window.location.href='$ref'},1000)</script>";
}else{
    if($p_format=="json"){
            echo '{"Status":0,"ReturnCode":"添加失败"}';
            return false;
        }
    echo "添加失败!<a href='javascript:history.back()'>返回</a>";
}
 ?>